package cn.how2go.net.server.protocol;

/**
 * Created by Administrator on 2018/4/19.
 */
public enum MessageType {
    JT_0001("终端通用应答",0x0001),
    JT_0002("终端心跳",0x0002),
    JT_0003("终端注销",0x0003),
    JT_0100("终端注册",0x0100),
    JT_0102("终端鉴权",0x0102),
    JT_0200("位置信息汇报",0x0200),
    JT_0704("位置信息汇报补报",0x0704),

    JT_8001("平台通用应答",0x8001),
    JT_8100("终端注册应答",0x8100);

    private String name;
    private int id;

    private MessageType(String name, int id){
        this.name = name;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    // 根据value返回枚举类型,主要在switch中使用
    public static MessageType getByValue(int value) {
        for (MessageType type : values()) {
            if (type.getId() == value) {
                return type;
            }
        }
        return null;
    }
}
